import torch

# 隐藏层输出 [2, 3, 4]
ts1 = torch.randn(2, 3, 4)
print(f'ts1-->{ts1}')

# mask [2, 3]
ts2 = torch.tensor([[1, 1, 0], [1, 1, 1]])
print(f'ts2-->{ts2}')

# 升维 [2, 3, 1]
ts2 = ts2.unsqueeze(-1)
print(f'ts2-->{ts2}')

# 对位相乘
result = ts1 * ts2
print(f'result-->{result}')